

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    broswer = p.chromium.launch(headless=False)
    page = broswer.new_page()
    page.goto("https://www.layui1.com/demo/upload.html")
    # input_loc = page.locator("input[name='wd']")
    # input_loc.fill('python')
    # input_loc.clear()
    # page.fill('input[name="wd"]', 'python')

    page.wait_for_timeout(1000)
    # page.locator('').click()
    # // *[ @ id = "test1"]
    # // *[ @ id = "LAY_preview"] / div[1] / input
    # page.locator('//*[@id="LAY_preview"]/div[1]/input').set_input_files('44.png')

    # page.locator('//*[@id="LAY_preview"]/div[3]/input').set_input_files(['44.png','44.png'])
    page.get_by_role("button", name="上传图片", exact=True).click()
    page.get_by_role("button", name="上传图片", exact=True).set_input_files("1.png")
    page.wait_for_timeout(5000)
